package me.spring.cloud.components.starter.number.number;

import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
import me.spring.cloud.common.components.number.generator.NumberGenerator;
import me.spring.cloud.common.components.number.rule.domain.BillNumberProperties;
import me.spring.cloud.components.starter.number.dynamic.DynamicBillNumberConfiguration;
import me.spring.cloud.components.starter.number.number.generator.ConfigBillNumGenerator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

/**
 * @description: bill number配置
 * @author: luffy
 * @create: 2018-09-12 17:42
 **/
@Slf4j
@EnableApolloConfig(DynamicBillNumberConfiguration.namespaces)
@Import(DynamicBillNumberConfiguration.class)
public class BillNumberConfiguration {

  @Autowired
  private BillNumberProperties billNumberProperties;

  @Bean
  public NumberGenerator numberGenerator() {
    NumberGenerator numberGenerator = new ConfigBillNumGenerator();
    numberGenerator.setNumberRules(billNumberProperties);
    return numberGenerator;
  }
}
